﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Bilibili
{
    class ListViewSort : IComparer
    {
        private int index;

        public ListViewSort(int index) {
            this.index = index;
        }
        public int Compare(object x, object y)
        {
            int c = 0;
            switch (index) {
                case 0:
                case 2:
                    c = string.Compare(((ListViewItem)x).SubItems[index].Text, ((ListViewItem)y).SubItems[index].Text);
                    break;

                case 1:
                case 4:
                    c = Convert.ToInt32(((ListViewItem)x).SubItems[index].Text) > Convert.ToInt32(((ListViewItem)y).SubItems[index].Text) ?0:-1;
                    break;
            }
            return c;
        }
    }
}
